/**  
 * All rights Reserved, Designed By www.beonelot.com
 * @Package: com.jinxin.platform.eleinspect.service.impl
 * @Filename: EleinspectRecordServiceImpl.java
 * @Description: TODO(EleinspectRecordService接口实现)
 * @author: 金鑫智慧
 * @date: 2020-03-30
 * @version: V1.0
 * @Copyright: 2020 www.beonelot.com Inc. All rights reserved.
 * 注意：本内容仅限于重庆金鑫智慧科技有限公司内部传阅，禁止外泄以及用于其他的商业目的
 */
package com.jinxin.platform.cdelecinspect.service.impl;

import com.jinxin.platform.cdelecinspect.mapper.EleinspectPointManageMapper;
import com.jinxin.platform.cdelecinspect.mapper.EleinspectRecordMapper;
import com.jinxin.platform.cdelecinspect.mapper.pojo.EleinspectPointManage;
import com.jinxin.platform.cdelecinspect.mapper.pojo.EleinspectPointRecords;
import com.jinxin.platform.cdelecinspect.mapper.pojo.EleinspectRecord;
import com.jinxin.platform.cdelecinspect.service.EleinspectRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * TODO(EleinspectRecordService接口实现)
 * @Classn: EleinspectRecordServiceImpl
 * @author Lynn
 * @date 2020-03-30
 */
@Service
public class EleinspectRecordServiceImpl implements EleinspectRecordService {
    @Autowired
    private EleinspectRecordMapper recordMapper;
    @Autowired
    private EleinspectPointManageMapper pointManageMapper;

    @Override
    public List listLineRecords(HashMap param) {
        return recordMapper.listLineRecords(param);
    }

    @Override
    public int listLineRecordsCount(HashMap param) {
        return recordMapper.listLineRecordsCount(param);
    }

    @Override
    public List<EleinspectPointRecords> listPointResultsById(String recordId) {
        HashMap param = new HashMap();
        param.put("recordTaskId",recordId);
        List<EleinspectRecord> recordList = recordMapper.list(param);
        if(recordList.size() > 0){
            List<EleinspectPointRecords> list = new ArrayList<>();
            for (EleinspectRecord record : recordList) {
                EleinspectPointManage po = pointManageMapper.selectByKey(record.getRecordPointId());
                EleinspectPointRecords entity = new EleinspectPointRecords();
                entity.setPointId(record.getRecordPointId());
                entity.setPointName(po.getPointName());
                entity.setRecordInspectTime(record.getRecordInspectTime());
                list.add(entity);
            }
            return list;
        }
        return null;
    }

    @Override
    public List<EleinspectRecord> list(HashMap param) {
        return recordMapper.list(param);
    }

    @Override
    public int updateByKey(EleinspectRecord eleinspectRecord) {
        return recordMapper.updateByKey(eleinspectRecord);
    }

    @Override
    public EleinspectRecord selectByKey(String recordId) {
        return recordMapper.selectByKey(recordId);
    }
    @Override
    public EleinspectRecord getOne(HashMap param) {
        return recordMapper.selectOne(param);
    }
}
